<?php
include_once("inc/conn.php");
include_once("inc/function.php");
include_once("heheadmin/inc/config.php");
login_check();

if (empty($_COOKIE["usersid"]) || empty($_COOKIE["password"])){
	if(isset($_SESSION["usersid"]))
	{
		setcookie("usersid",$_SESSION["usersid"]);
        setcookie("username",$_SESSION["username"]);
        setcookie("password",$_SESSION["password"]);
	}
} else {
    if(!isset($_SESSION['usersid']))
    {
        $username = str_check($_COOKIE["username"]);
        $pwd = str_check($_COOKIE["password"]);
        
        $username = (strlen($username) > 50) ? substr($username,0,50) : $username;
        $pwd = (strlen($pwd) > 32) ? substr($pwd,0,32) : $pwd;
        
        $ip = usersip();
        $sql = "call web_user_login('{$username}','{$pwd}','{$ip}')";
        $arr = $db->Mysqli_Multi_Query($sql);
        if($arr[0][0]["result"] == '0'){
            $_SESSION["usersid"] = $arr[0][0]["userid"];
            $_SESSION["username"] = $arr[0][0]["username"];
            $_SESSION["nickname"] = $arr[0][0]["nickname"];
            $_SESSION["points"] = $arr[0][0]["points"];
            $_SESSION["bankpoints"] = $arr[0][0]["bankpoint"];
            $_SESSION["exp"] = $arr[0][0]["experience"]; 
            $_SESSION['freeze'] = 0;
        }
        else
        {
             unset($_SESSION['usersid']);
             session_destroy();    
        }
    }
    RefreshPoints();
    if(isset($_SESSION['freeze']) && $_SESSION['freeze'] == 1)
	{
		//退出
		session_destroy();
	}
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $web_name;?> -领取红包</title>
<?php 
    require 'public/title.inc.php';
?>
<link rel="stylesheet" type="text/css" href="style/Redpackage.css" />
<script type="text/javascript" src="js/Redpackage.js"></script>
</head>
<body>
<? include_once("top.php");?> 
    	<div class="com">
    	   <form action="?success" method="post">
        	<ul class="text"> 
            	<li><h2>请填写以下信息领取红包</h2></li>           
                 <li><span>发起人昵称：</span><input id="redname" type="hidden" >陈小红</li>
                <li><span>你的ID号：</span><input id="tjid" name="tjid" type="text" class="mane" maxlength="8" placeholder="你的ID号"></li>
                <li><span>验证码：</span><input id="vcode" type="text" class="yzm" placeholder="验证码" maxlength="4"><img class="yzm_img" style="cursor: pointer;" alt="看不清请点击更换" src="vcode.php" onclick="this.src='vcode.php?t='+ Math.round(Math.random() * 10000)"></li>   
                <li class="btn"><input id="reg" type="submit" class="ntb" value="领取红包"></li><p></p>
                
            </ul>
          </form>
            <ul class="associate2">
            	
            </ul>
        </div>
<? include_once("footer.php");?>
</body>
</html>

